// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Utils from './util/util'

Vue.config.productionTip = false;

import store from './store';
import Mint from 'mint-ui';
Vue.use(Mint);
import 'mint-ui/lib/style.css'; 

import Element from 'element-ui'
import './theme/element-variables.scss'

Vue.use(Element);

router.beforeEach((to, from, next) => {
  // if (to.matched.some(record => record.meta.requireLogin)) { // 判断该路由是否需要登录权限
  //     if (localStorage.getItem('user_token')) { // 判断当前用户的登录信息loginInfo是否存在
  //         next();
  //     } else {
  //         next({
  //             path: '/login'
  //         });
  //     }
  // } else {
  //     next();
  // }
  //   第一次进入项目
  let token = localStorage.getItem('user_token');
  if (!token && to.path != '/login') {
      window.localStorage.setItem('beforeLoginUrl', to.fullPath) // 保存用户进入的url
      
      next('/login')
      return false
  }
  //localStorage.setItem('user_token', 'a7696e0c7d33c271fee848127bd4fc40');

  next()

})

// 定义方法
Vue.prototype.$utils = Utils;

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
